﻿using Naruto.Configuration;
using Naruto.Configuration.Core;
using Naruto.Configuration.RedisProvider;
using System;

namespace Microsoft.Extensions.DependencyInjection
{
    public static class RedisProviderExtensions
    {
        /// <summary>
        /// 注入配置更新服务
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public static IServiceCollection AddNarutoConfigurationSubscribe(this IServiceCollection services)
        {
            services.AddSingleton<ISubscribeReload, RedisSubscribeReloadData>();
            return services;
        }


        /// <summary>
        /// 注入发布配置更新通知的服务
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public static IServiceCollection AddNarutoConfigurationPublish(this IServiceCollection services)
        {
            services.AddSingleton<IConfigurationPublish, DefaultConfigurationPublish>();
            return services;
        }
    }
}
